:root {
  --bg: #f5f7f6;
  --panel: #ffffff;
  --text: #18211f;
  --muted: #66746f;
  --line: #dce5e0;
  --brand: #1f7a63;
  --brand-dark: #155f4d;
  --logo-blue: #2468dc;
  --logo-cyan: #18bcd6;
  --logo-violet: #7043c8;
  --logo-magenta: #c337b7;
  --logo-gold: #f2a51f;
  --soft: #eef4f1;
  --danger: #b73535;
  --warn: #a66a1d;
  --shadow: 0 12px 30px rgba(20, 45, 38, 0.07);
}

:root[data-theme="dark"] {
  --bg: #0f1713;
  --panel: #18211d;
  --text: #f3faf6;
  --muted: #b8cbc3;
  --line: #3a4b43;
  --brand: #66c39e;
  --brand-dark: #99e6c5;
  --logo-blue: #4d8dff;
  --logo-cyan: #3bd8e7;
  --logo-violet: #9b7bf0;
  --logo-magenta: #e062d2;
  --logo-gold: #ffc767;
  --soft: #25362f;
  --danger: #ef7d7d;
  --warn: #f0b35b;
  --shadow: 0 16px 36px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  display: grid;
  grid-template-columns: 226px minmax(0, 1fr);
  min-height: 100vh;
  font-size: 13px;
  line-height: 1.42;
}

a {
  color: inherit;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px 10px;
}

.brand {
  display: block;
  text-align: center;
  margin-bottom: 8px;
}

.brand-name {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 11.5px;
  font-weight: 900;
  line-height: 1.08;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-logo {
  display: block;
  width: 132px;
  height: 104px;
  margin: 0 auto;
  object-fit: contain;
  border: 0;
  background: transparent;
  box-shadow: none;
  filter: drop-shadow(0 12px 18px rgba(15, 38, 34, 0.12));
}

.brand-services {
  display: grid;
  gap: 6px;
  margin: 8px 4px 10px;
}

.brand-service {
  --service-color: var(--brand);
  display: grid;
  grid-template-columns: 25px 1fr;
  gap: 8px;
  align-items: center;
  color: var(--text);
  font-size: 12.3px;
  line-height: 1.1;
  font-weight: 500;
}

.brand-service-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--service-color);
}

.brand-service-icon .action-icon {
  width: 18px;
  height: 18px;
}

.service-contable {
  --service-color: var(--brand-dark);
}

.service-seguros {
  --service-color: var(--logo-blue);
}

.service-finanzas {
  --service-color: var(--logo-violet);
}

.brand-divider {
  height: 1px;
  margin: 11px 3px;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
}

:root[data-theme="dark"] .brand-logo {
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.32));
}

.nav-link {
  display: grid;
  grid-template-columns: 29px 1fr;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 6px 9px;
  border-radius: 10px;
  text-decoration: none;
  margin-bottom: 2px;
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
  position: relative;
  transition: transform 0.11s ease, background 0.11s ease, color 0.11s ease, box-shadow 0.11s ease;
}

.nav-link-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
}

.nav-link-icon .action-icon {
  width: 20px;
  height: 20px;
}

.nav-link.active,
.nav-link:hover {
  background: linear-gradient(90deg, color-mix(in srgb, var(--brand) 14%, var(--panel)), var(--soft));
  color: var(--brand-dark);
}

.nav-link:hover {
  transform: translateX(2px);
}

.nav-link:hover .action-icon,
.nav-link.active .action-icon {
  transform: scale(1.18);
}

.main {
  padding: 24px;
  max-width: 1500px;
  width: 100%;
}

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

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

.notification-wrap {
  position: relative;
}

.notification-button {
  gap: 5px;
  min-width: 48px;
  position: relative;
}

.notification-button span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}

.notification-wrap:not(.has-alerts) .notification-button span {
  background: var(--muted);
}

.notification-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(390px, calc(100vw - 32px));
  max-height: 460px;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 8px;
  z-index: 20;
}

.notification-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 10px;
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  border-radius: 9px;
}

.notification-item:last-child {
  border-bottom: 0;
}

.notification-item:hover {
  background: var(--soft);
}

.notification-dot {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 999px;
  background: var(--brand);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent);
}

.notification-item.task .notification-dot {
  background: #f0a629;
  box-shadow: 0 0 0 4px rgba(240, 166, 41, 0.18);
}

.notification-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.notification-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notification-copy small {
  color: var(--muted);
  font-size: 12px;
}

.notification-footer {
  display: block;
  padding: 10px;
  margin-top: 4px;
  border-radius: 9px;
  background: var(--soft);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
  text-decoration: none;
}

.notification-empty {
  padding: 12px;
  margin: 0;
}

.login-body {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
}

.login-shell {
  width: min(430px, 100%);
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-brand {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.login-brand span {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.login-brand small,
.login-card p {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.login-error {
  margin-top: 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  background: color-mix(in srgb, var(--danger) 12%, var(--panel));
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 700;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--brand-dark);
  background: var(--panel);
}

.topbar small {
  color: color-mix(in srgb, var(--logo-gold) 74%, var(--text));
  font-weight: 800;
  text-transform: uppercase;
  font-size: 11px;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 27px;
  line-height: 1.08;
}

h2 {
  font-size: 19px;
  line-height: 1.12;
}

h3 {
  font-size: 15.5px;
  line-height: 1.18;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 16px;
  box-shadow: var(--shadow);
}

:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .dash-card,
:root[data-theme="dark"] .sidebar {
  border-color: var(--line);
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 16px;
}

.section-title p {
  color: var(--muted);
  margin: 6px 0 0;
  font-size: 12.5px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  align-items: start;
}

.dash-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
  min-height: 212px;
  height: 212px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.dash-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.dash-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.dash-title-wrap h3 {
  margin: 0;
}

.dash-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 82%, #fff 18%), var(--soft));
  border: 1px solid var(--line);
  color: var(--text);
}

.dash-icon .action-icon {
  width: 22px;
  height: 22px;
}

.dash-head strong {
  font-size: 28px;
  color: var(--brand-dark);
}

.dash-list {
  display: grid;
  gap: 8px;
  max-height: 122px;
  overflow: auto;
  padding-right: 4px;
}

.dash-item {
  border-top: 1px solid var(--line);
  padding-top: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.dash-item-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.dash-item-main .strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-actions {
  gap: 5px;
  flex-wrap: nowrap;
}

.dash-actions .icon-btn {
  width: 34px;
  min-width: 34px;
  min-height: 32px;
  border-radius: 9px;
}

.dash-actions .action-icon {
  width: 19px;
  height: 19px;
}

.dash-details summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #1e2c47;
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 85%, #fff 15%), var(--soft));
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: 9px;
  box-shadow: 0 5px 14px rgba(22, 44, 37, 0.06);
  margin-bottom: 8px;
  width: 34px;
  height: 32px;
  list-style: none;
  position: relative;
  transition: transform 0.11s ease, border-color 0.11s ease, background 0.11s ease, box-shadow 0.11s ease;
}

.dash-details summary:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--brand) 38%, var(--line));
  box-shadow: 0 10px 22px rgba(22, 44, 37, 0.13);
}

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

.dash-details summary::marker {
  content: "";
}

.dash-details summary .action-icon {
  width: 18px;
  height: 18px;
}

.dash-more {
  display: block;
  color: var(--muted);
  font-weight: 800;
  padding: 3px 0 0;
}

.dash-empty {
  grid-column: 1 / -1;
  min-height: 140px;
  display: grid;
  align-content: center;
}

.panel.narrow {
  max-width: 900px;
}

.toolbar,
.record-head,
.form-actions,
.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.actions form {
  margin: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.toolbar,
.record-head {
  justify-content: space-between;
  margin-bottom: 16px;
}

.search-form {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 280px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  font: inherit;
  background: var(--panel);
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent);
  border-color: var(--brand);
}

textarea {
  min-height: 88px;
}

input[type="file"] {
  padding: 8px;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 7px;
  background: var(--brand);
  color: white;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.icon-btn {
  width: 38px;
  min-width: 38px;
  min-height: 36px;
  padding: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 85%, #fff 15%), var(--soft));
  color: #1e2c47;
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  box-shadow: 0 5px 14px rgba(22, 44, 37, 0.06);
  line-height: 1;
  position: relative;
  transition: transform 0.11s ease, border-color 0.11s ease, background 0.11s ease, box-shadow 0.11s ease, color 0.11s ease;
}

.icon-btn:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--brand) 38%, var(--line));
  box-shadow: 0 10px 22px rgba(22, 44, 37, 0.15);
}

.icon-btn:active {
  transform: translateY(0);
}

.icon-btn.is-copied {
  color: var(--brand-dark);
  border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
  background: color-mix(in srgb, var(--brand) 16%, var(--panel));
}

.icon-btn.danger,
button.icon-btn.danger {
  background: linear-gradient(180deg, #fff7f7, #fdecec);
  color: #9f2e2e;
  border-color: #f0c5c5;
}

:root[data-theme="dark"] .icon-btn {
  background: linear-gradient(180deg, #22322c, #192620);
  color: #d9e9ff;
  border-color: #40554b;
  box-shadow: none;
}

:root[data-theme="dark"] .icon-btn.danger,
:root[data-theme="dark"] button.icon-btn.danger {
  background: linear-gradient(180deg, #3a2323, #2c1b1b);
  color: #ffb2b2;
  border-color: #784747;
}

:root[data-theme="dark"] .dash-details summary {
  background: linear-gradient(180deg, #22322c, #192620);
  color: #d9e9ff;
  border-color: #40554b;
  box-shadow: none;
}

.action-icon {
  width: 22px;
  height: 22px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.1s ease, filter 0.1s ease, stroke 0.1s ease;
  transform-origin: center;
}

.icon-btn:hover .action-icon,
.notification-button:hover .action-icon,
.filter-chip.icon-filter:hover .action-icon,
.dash-details summary:hover .action-icon {
  transform: scale(1.34) translateY(-1px);
  filter: drop-shadow(0 3px 6px rgba(20, 45, 38, 0.18));
}

:root[data-theme="dark"] .icon-btn:hover .action-icon,
:root[data-theme="dark"] .notification-button:hover .action-icon,
:root[data-theme="dark"] .filter-chip.icon-filter:hover .action-icon,
:root[data-theme="dark"] .dash-details summary:hover .action-icon {
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.35));
}

.action-icon .tone {
  stroke: currentColor;
}

.action-icon .accent {
  stroke: #4a78ff;
}

.action-icon .danger-stroke {
  stroke: #df4f4f;
}

.action-icon .whatsapp-stroke {
  stroke: #29b75f;
}

.action-icon .success-stroke {
  stroke: #39b66b;
}

.action-icon .ai-stroke {
  stroke: #7b61ff;
}

.crm-tooltip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px) scale(0.94);
  transform-origin: center;
  max-width: min(260px, calc(100vw - 20px));
  padding: 9px 12px;
  border-radius: 10px;
  background: #101a16;
  color: #f8fffb;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 14px 30px rgba(13, 28, 23, 0.22);
  font-size: 13.5px;
  font-weight: 850;
  line-height: 1.14;
  white-space: nowrap;
  letter-spacing: 0;
  transition: opacity 0.07s ease, transform 0.07s ease;
}

.crm-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.crm-tooltip[data-placement="right"] {
  transform: translateX(-4px) scale(0.94);
}

.crm-tooltip[data-placement="right"].is-visible {
  transform: translateX(0) scale(1);
}

.crm-tooltip[data-placement="bottom"] {
  transform: translateY(-4px) scale(0.94);
}

.crm-tooltip[data-placement="bottom"].is-visible {
  transform: translateY(0) scale(1);
}

:root[data-theme="dark"] .crm-tooltip {
  background: #f5fbf8;
  color: #0d1813;
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.34);
}

.actions {
  gap: 6px;
}

.actions .button,
.actions button {
  min-height: 32px;
}

.actions button.danger:not(.icon-btn) {
  width: 34px;
  min-width: 34px;
  padding: 0;
  font-size: 0;
}

.actions button.danger:not(.icon-btn)::before {
  content: "\1F5D1";
  font-size: 15px;
}

.button.secondary,
button.secondary {
  background: var(--soft);
  color: var(--text);
  border: 1px solid var(--line);
}

.button.small {
  padding: 7px 9px;
  font-size: 13px;
}

button.small {
  padding: 7px 9px;
  font-size: 13px;
}

button.danger,
.button.danger {
  background: #b84a4a;
  color: #fff;
}

button:disabled,
.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.danger:hover,
.button.danger:hover {
  background: #9f3737;
}

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

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

th {
  color: #52645e;
  font-size: 11px;
  letter-spacing: 0;
  text-transform: uppercase;
}

tr:hover td {
  background: var(--soft);
}

small,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.strong {
  font-weight: 800;
  text-decoration: none;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 28px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.8fr);
  gap: 16px;
}

.client-layout {
  display: grid;
  gap: 14px;
}

.client-summary {
  border-left: 4px solid var(--brand);
}

.info-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.info-strip article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.info-strip strong {
  display: block;
  font-size: 22px;
  color: var(--brand-dark);
}

.info-strip span {
  color: var(--muted);
  font-weight: 700;
}

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

.relationship-grid .interaction-panel {
  grid-column: 1 / -1;
}

.client-summary .field-grid {
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.compact-table th,
.compact-table td {
  padding: 8px 7px;
}

.quick-interaction {
  display: grid;
  grid-template-columns: 180px 220px 1fr 220px auto;
  gap: 9px;
  align-items: start;
  margin-bottom: 12px;
}

.quick-interaction textarea {
  min-height: 42px;
}

.communication-panel {
  display: grid;
  gap: 12px;
}

.communication-panel > .whatsapp-send-panel {
  order: 10;
}

.communication-panel > .quick-type-bar {
  order: 20;
  margin-top: 4px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.communication-panel > .quick-type-bar::before {
  content: "Registrar comunicación";
  flex: 0 0 100%;
  color: var(--text);
  font-size: 15px;
  font-weight: 900;
}

.communication-panel > .communication-form {
  order: 21;
}

.communication-panel > .communication-filters {
  order: 30;
  margin-top: 4px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.communication-panel > .communication-filters::before {
  content: "Historial";
  flex: 0 0 100%;
  color: var(--text);
  font-size: 15px;
  font-weight: 900;
}

.communication-panel > .timeline {
  order: 40;
  max-height: min(560px, calc(100vh - 260px));
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(47, 122, 99, 0.05) 25%, transparent 25%) 0 0 / 28px 28px,
    linear-gradient(315deg, rgba(47, 122, 99, 0.05) 25%, transparent 25%) 0 0 / 28px 28px,
    color-mix(in srgb, var(--panel) 88%, var(--soft));
  padding: 14px;
}

.communication-filters,
.quick-type-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--text);
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.filter-chip.icon-filter {
  width: 38px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 86%, #fff 14%), var(--soft));
  position: relative;
  transition: transform 0.11s ease, border-color 0.11s ease, background 0.11s ease, box-shadow 0.11s ease;
}

.filter-chip.icon-filter:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--brand) 38%, var(--line));
  box-shadow: 0 10px 22px rgba(22, 44, 37, 0.12);
}

.filter-chip.icon-filter .action-icon {
  width: 21px;
  height: 21px;
}

.filter-chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.filter-chip.active .action-icon .accent,
.filter-chip.active .action-icon .whatsapp-stroke,
.filter-chip.active .action-icon .success-stroke {
  stroke: #fff;
}

.suggested-message-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px);
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px;
  background: color-mix(in srgb, var(--panel) 88%, var(--soft));
}

.suggested-message-form label {
  grid-row: span 2;
}

.suggested-message-form textarea {
  min-height: 92px;
}

.whatsapp-send-panel {
  display: grid;
  grid-template-columns: 170px 240px minmax(280px, 1fr) auto;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px;
  background: color-mix(in srgb, var(--panel) 88%, var(--soft));
}

.whatsapp-send-panel .message-box textarea {
  min-height: 78px;
}

.mini-title {
  font-weight: 900;
  color: var(--brand-dark);
  margin-bottom: 4px;
}

.communication-notice {
  margin: 0;
}

.field-grid,
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

.field {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 88%, var(--soft));
  border-radius: 8px;
  padding: 11px;
}

.field strong {
  display: block;
  color: #155f4d;
  font-size: 11px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  color: #52645e;
}

.task-title-field {
  color: var(--text);
}

.task-title-field input {
  font-size: 18px;
  font-weight: 800;
  padding: 12px 13px;
}

:root[data-theme="dark"] label,
:root[data-theme="dark"] th {
  color: #c8d9d2;
}

.span-2 {
  grid-column: span 2;
}

.check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.tag-fieldset legend {
  padding: 0 6px;
  font-weight: 800;
  color: #155f4d;
}

.tag-choice {
  display: inline-flex;
  align-items: center;
  width: auto;
  cursor: pointer;
}

.tag-choice input {
  width: auto;
  margin-right: 4px;
}

.quick-tag-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 46px minmax(180px, auto);
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.quick-tag-row input[type="color"] {
  padding: 3px;
  height: 38px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  color: var(--text);
}

.check input {
  width: auto;
}

.tag {
  --tag-color: #6b7280;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: lowercase;
  background: color-mix(in srgb, var(--tag-color) 22%, white);
  color: #14352c;
  margin: 1px;
}

.tag-edit {
  gap: 6px;
}

.tag-edit button {
  width: 17px;
  height: 17px;
  padding: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--tag-color) 40%, #000);
  color: #fff;
  font-size: 12px;
  line-height: 1;
}

:root[data-theme="dark"] .tag {
  background: color-mix(in srgb, var(--tag-color) 54%, #101713);
  color: #f7fffb;
  border: 1px solid color-mix(in srgb, var(--tag-color) 64%, var(--line));
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  background: #eef4f1;
  color: #155f4d;
  font-size: 12px;
  font-weight: 800;
}

:root[data-theme="dark"] .pill {
  background: #25362f;
  color: #d9fff0;
  border: 1px solid var(--line);
}

.pill.ok {
  background: #e7f4ec;
  color: #17603e;
}

:root[data-theme="dark"] .pill.ok {
  background: #1d4031;
  color: #bdf4d7;
}

.pill.warn {
  background: #fff4df;
  color: #80520f;
}

:root[data-theme="dark"] .pill.warn {
  background: #46341e;
  color: #f6cf8f;
}

.pill.muted-pill {
  background: #eef0f1;
  color: #5d6662;
}

:root[data-theme="dark"] .pill.muted-pill {
  background: #26312d;
  color: #c9d8d2;
}

.pill.danger-soft {
  background: #fde8e8;
  color: #a13131;
}

:root[data-theme="dark"] .pill.danger-soft {
  background: #4a2424;
  color: #ffb5b5;
}

.pill.sendpulse-pill {
  background: #e6f7ef;
  color: #0e6a47;
  border: 1px solid #b8e4cf;
}

:root[data-theme="dark"] .pill.sendpulse-pill {
  background: #173b2d;
  color: #bff6d9;
  border-color: #2f7a63;
}

.timeline {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.communication-panel .timeline {
  align-content: start;
  gap: 9px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  position: relative;
}

.communication-panel .timeline-item {
  display: flex;
  grid-template-columns: none;
  gap: 0;
}

.communication-panel .timeline-item::before,
.communication-panel .timeline-dot {
  display: none;
}

.communication-panel .timeline-item.message-out {
  justify-content: flex-end;
}

.communication-panel .timeline-item.message-in,
.communication-panel .timeline-item.message-neutral {
  justify-content: flex-start;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 18px;
  bottom: -14px;
  width: 1px;
  background: var(--line);
}

.timeline-item:last-child::before {
  display: none;
}

.timeline-dot {
  width: 10px;
  height: 10px;
  margin-top: 12px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--panel);
  box-shadow: 0 0 0 2px var(--brand);
  z-index: 1;
}

.timeline-dot.channel-whatsapp,
.channel-badge.channel-whatsapp {
  --channel-color: #1d8f62;
}

.timeline-dot.channel-email,
.channel-badge.channel-email {
  --channel-color: #2563a8;
}

.timeline-dot.channel-llamada,
.channel-badge.channel-llamada {
  --channel-color: #7c5aa6;
}

.timeline-dot.channel-reunion,
.channel-badge.channel-reunion {
  --channel-color: #b8792a;
}

.timeline-dot.channel-documento,
.channel-badge.channel-documento {
  --channel-color: #607080;
}

.timeline-dot.channel-cotizacion,
.channel-badge.channel-cotizacion {
  --channel-color: #a85a5a;
}

.timeline-dot.channel-nota,
.channel-badge.channel-nota,
.timeline-dot.channel-comunicacion,
.channel-badge.channel-comunicacion {
  --channel-color: #2f7a63;
}

.timeline-dot[class*="channel-"] {
  background: var(--channel-color);
  box-shadow: 0 0 0 2px var(--channel-color);
}

.timeline-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 12px;
  background: color-mix(in srgb, var(--panel) 92%, var(--soft));
}

.communication-panel .message-bubble {
  width: fit-content;
  max-width: min(76%, 760px);
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 9px 10px 8px;
  box-shadow: 0 6px 16px rgba(16, 24, 20, 0.08);
}

.communication-panel .message-out .message-bubble {
  border-bottom-right-radius: 4px;
  background: #d9f6e8;
  color: #073b2b;
}

.communication-panel .message-in .message-bubble {
  border-bottom-left-radius: 4px;
  background: #ffffff;
  color: #1f2a24;
  border-color: #d7e2dc;
}

.communication-panel .message-neutral .message-bubble {
  background: #edf3ef;
  color: #1f2a24;
  border-color: #d7e2dc;
}

:root[data-theme="dark"] .communication-panel > .timeline {
  background:
    linear-gradient(135deg, rgba(99, 181, 148, 0.07) 25%, transparent 25%) 0 0 / 28px 28px,
    linear-gradient(315deg, rgba(99, 181, 148, 0.07) 25%, transparent 25%) 0 0 / 28px 28px,
    #111915;
}

:root[data-theme="dark"] .communication-panel .message-out .message-bubble {
  background: #1f7257;
  color: #f4fff9;
  border-color: #2f8c6d;
}

:root[data-theme="dark"] .communication-panel .message-in .message-bubble {
  background: #202b25;
  color: #f3faf6;
  border-color: #3a4d43;
}

:root[data-theme="dark"] .communication-panel .message-neutral .message-bubble {
  background: #1b241f;
  color: #f3faf6;
  border-color: #3a4d43;
}

.timeline-card p {
  margin: 8px 0;
  line-height: 1.45;
}

.communication-panel .message-text {
  margin: 7px 0 5px;
  color: inherit;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.38;
  white-space: pre-wrap;
}

.communication-panel .message-detail {
  display: block;
  color: currentColor;
  font-size: 11px;
  opacity: 0.68;
}

.timeline-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.timeline-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.communication-panel .timeline-actions {
  gap: 5px;
}

.communication-panel .message-time {
  color: currentColor;
  font-size: 11px;
  font-weight: 700;
  opacity: 0.62;
  white-space: nowrap;
}

.timeline-actions form {
  margin: 0;
}

.timeline-delete {
  width: 24px;
  min-height: 24px;
  padding: 0;
  border-radius: 50%;
  font-size: 13px;
  line-height: 1;
  opacity: 0.72;
}

.timeline-delete:hover {
  opacity: 1;
}

.timeline-tags {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.channel-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 900;
  color: #fff;
  background: var(--channel-color, var(--brand));
}

.filter-panel,
.inline-form {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: color-mix(in srgb, var(--panel) 88%, var(--soft));
}

.filter-panel label {
  min-width: 180px;
}

.inline-form input[type="color"] {
  width: 46px;
  height: 39px;
  padding: 3px;
}

.tag-builder {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: color-mix(in srgb, var(--panel) 88%, var(--soft));
}

.tag-builder-row,
.tag-row-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 48px auto;
  gap: 8px;
  align-items: center;
}

.tag-row-form {
  grid-template-columns: minmax(150px, 1fr) 48px minmax(130px, 1fr) auto;
}

.tag-builder-row input[type="color"],
.tag-row-form input[type="color"] {
  height: 38px;
  padding: 3px;
}

.tag-builder-preview {
  min-height: 28px;
}

.ok-alert {
  background: #e9f8ef;
  border-color: #bee9ce;
  color: #17603e;
}

:root[data-theme="dark"] .ok-alert {
  background: #193427;
  border-color: #315c47;
  color: #bdf4d7;
}

.info-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: color-mix(in srgb, var(--panel) 88%, var(--soft));
  color: var(--muted);
}

.info-box p {
  margin: 6px 0 0;
}

.info-box code {
  color: var(--text);
  font-weight: 700;
}

.import-preview-panel {
  margin-top: 12px;
}

.pdf-preview summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--brand-dark);
}

.pdf-preview pre {
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 88%, var(--soft));
  padding: 12px;
  color: var(--text);
  font: 12px/1.45 Consolas, "Courier New", monospace;
}

.linked-list {
  padding-left: 18px;
}

.linked-list li {
  margin: 8px 0;
}

.attachment-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-upload {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-upload input[type="file"] {
  max-width: 380px;
}

.inline-delete {
  display: inline-flex;
}

.detail-note {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 14px;
}

.alert {
  background: #fff0f0;
  border: 1px solid #f0caca;
  color: var(--danger);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
  white-space: pre-wrap;
}

:root[data-theme="dark"] .alert {
  background: #3a2020;
  border-color: #6d3434;
  color: #ffc3c3;
}

:root[data-theme="dark"] table {
  color: var(--text);
}

:root[data-theme="dark"] button,
:root[data-theme="dark"] .button {
  color: #06120e;
}

:root[data-theme="dark"] button.secondary,
:root[data-theme="dark"] .button.secondary {
  color: var(--text);
}

:root[data-theme="dark"] button.danger,
:root[data-theme="dark"] .button.danger {
  color: #190808;
  background: #ef7d7d;
}

@media (max-width: 900px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .detail-grid,
  .relationship-grid,
  .field-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

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

  .quick-interaction {
    grid-template-columns: 1fr;
  }

  .whatsapp-send-panel {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }
}
