/* Dashboard cards, account home, charts, tables, logs, prompts, media, and API docs. */
.account-home {
  display: grid;
  gap: 16px;
}

.account-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
}

.account-home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.account-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.06);
  padding: 14px;
  display: grid;
  gap: 10px;
  min-height: 142px;
}

.account-card.clickable {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.account-card.clickable:hover {
  transform: translateY(-2px);
  border-color: #b8c8cb;
  box-shadow: 0 14px 30px rgba(17, 24, 39, 0.1);
}

.account-card-head {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  align-items: center;
}

.account-card-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #eef7f4;
  color: var(--accent-2);
  font-weight: 900;
}

.account-card-meta {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
}

.account-create-card {
  border-style: dashed;
  background: #fbfaf6;
}

.account-create-inline {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.integration-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.integration-summary-card {
  position: relative;
  overflow: hidden;
  border-color: #d9e5e8;
}

.integration-summary-card::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: #0d6f5d;
}

.lead-name-cell {
  display: grid;
  gap: 3px;
}

.id-chip {
  direction: ltr;
  text-align: right;
  color: var(--muted);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
}

h1, h2, h3 { margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 18px; margin-bottom: 10px; }

input, select, textarea, button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  min-width: 0;
}

button {
  cursor: pointer;
  background: var(--accent);
  color: white;
  border: none;
  font-weight: 700;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

button:hover { transform: translateY(-1px); }
button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}
button.secondary { background: #263342; }
button.danger { background: var(--danger); }

.refresh-button,
.sidebar-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  white-space: nowrap;
}

.refresh-button {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}

.refresh-button svg,
.sidebar-logout svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 10px;
}

.tabs {
  display: grid;
  gap: 8px;
}

.tabs button {
  width: 100%;
  background: transparent;
  color: #e5e7eb;
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: right;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 44px;
  box-shadow: none;
}

.tabs button:hover {
  transform: none;
  background: rgba(255, 255, 255, 0.08);
}

.tabs button.active {
  background: #c8a45d;
  color: #111827;
  border-color: #c8a45d;
  box-shadow: inset 3px 0 0 rgba(17, 24, 39, 0.34);
}

.sidebar-spacer { flex: 1; }

.sidebar-logout {
  width: 100%;
  background: var(--sidebar-soft);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.section[hidden] { display: none; }

.kpi {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: linear-gradient(140deg, #fff, #fbfaf6);
}

.kpi .label { font-size: 13px; color: var(--muted); }
.kpi .value { font-size: 28px; font-weight: 800; margin-top: 6px; }
.kpi.money .value { font-size: 24px; direction: ltr; text-align: right; }

.main {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 14px;
  min-height: 620px;
}

.conversations-main {
  display: grid;
  grid-template-columns: minmax(520px, 1.15fr) minmax(420px, 0.85fr);
  gap: 14px;
  min-height: 620px;
  align-items: start;
}

.dashboard-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.date-filter-row {
  display: grid;
  grid-template-columns: minmax(160px, 210px) 150px 150px auto;
  gap: 8px;
  align-items: center;
}

.filters {
  display: grid;
  grid-template-columns: minmax(190px, 2fr) repeat(3, minmax(120px, 1fr)) auto;
  gap: 8px;
  margin-bottom: 10px;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 10px;
}

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

.chart-card {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.chart-card.wide {
  grid-column: span 2;
}

.chart-bars,
.mini-chart,
.activity-chart {
  display: grid;
  gap: 9px;
}

.chart-row {
  display: grid;
  grid-template-columns: minmax(92px, 128px) 1fr minmax(42px, 76px);
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.chart-row .label {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--muted);
}

.chart-track {
  height: 10px;
  border-radius: 999px;
  background: #e9eeec;
  overflow: hidden;
}

.chart-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-2), #c8a45d);
}

.activity-chart {
  grid-template-columns: repeat(auto-fit, minmax(34px, 1fr));
  align-items: end;
  min-height: 184px;
  padding-top: 6px;
}

.activity-day {
  min-width: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 6px;
  align-items: end;
}

.activity-stack {
  height: 136px;
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
  gap: 2px;
  background: #eef2f0;
  border-radius: 6px;
  padding: 3px;
}

.activity-segment {
  border-radius: 4px;
}

.activity-segment.leads { background: var(--accent-2); }
.activity-segment.meetings { background: #c8a45d; }
.activity-segment.handoffs { background: #263342; }

.activity-label {
  direction: ltr;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.legend-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-inline-end: 5px;
}

.table-wrap { max-height: 420px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  direction: rtl;
}

th, td {
  border-bottom: 1px solid #edf1f4;
  padding: 8px;
  text-align: right;
  vertical-align: top;
}

tr:hover { background: #f8fbfb; }
tr.active { background: var(--soft); }

.chat-panel {
  display: grid;
  grid-template-rows: auto auto auto minmax(360px, 1fr) auto;
  gap: 12px;
  min-height: 0;
}

.conversation-header {
  display: grid;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid #edf1f4;
}

.conversation-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}

.conversation-action-group {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  box-shadow: 0 6px 14px rgba(20, 34, 45, 0.035);
}

.conversation-action-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
}

.conversation-action-head h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.2;
}

.conversation-action-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 6px;
}

.conversation-inline-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}

.conversation-action-group button,
.conversation-action-group select,
.conversation-action-group input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  font-size: 14px;
}

.meeting-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.meeting-controls input[type="datetime-local"] {
  min-width: 190px;
  max-width: 100%;
}

.internal-notes-panel {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.internal-notes-panel label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.internal-notes-panel textarea {
  min-height: 92px;
  resize: vertical;
  direction: rtl;
  text-align: right;
}

.internal-notes-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.meeting-tag {
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f4faf8;
}

.handoff-tag.locked {
  color: #7f1d1d;
  background: #fff1f2;
  border-color: #fecdd3;
}

.handoff-tag.open {
  color: #14532d;
  background: #f0fdf4;
  border-color: #bbf7d0;
}

button.secondary.ghost {
  background: #f0f5f8;
  color: #203240;
  border: 1px solid #c9d7df;
}

button.secondary.ghost[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

button.danger.ghost {
  background: #fff1f2;
  color: var(--danger);
  border: 1px solid #fecdd3;
}

button.danger.ghost[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.chat-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  overflow-y: auto;
  background: #f9fbfc;
  min-height: 410px;
  max-height: 520px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.msg {
  max-width: 80%;
  padding: 10px;
  border-radius: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.msg.lead { justify-self: start; background: #ffffff; border: 1px solid var(--line); }
.msg.assistant { justify-self: end; background: #dcf7ef; border: 1px solid #b2ead9; }

.direct-message-panel {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.direct-message-panel label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.direct-message-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.direct-message-row textarea {
  min-height: 54px;
  max-height: 160px;
  resize: vertical;
  direction: rtl;
  text-align: right;
}

.direct-message-row button {
  min-height: 54px;
  white-space: nowrap;
}

.meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 5px;
}

.stack {
  display: grid;
  gap: 12px;
}

.errors-list, .meetings-list {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: #fbfdff;
}

.error-item, .meeting-item {
  border-bottom: 1px solid #ebf0f2;
  padding: 8px 4px;
  font-size: 13px;
}

.error-item:last-child, .meeting-item:last-child { border-bottom: none; }

.error-item .title { color: var(--danger); font-weight: 700; }
.tiny { font-size: 12px; color: var(--muted); }

.logs-toolbar {
  display: grid;
  grid-template-columns: minmax(130px, 170px) 140px 140px minmax(120px, 150px) minmax(150px, 1fr) minmax(150px, 1fr) minmax(150px, 1fr) minmax(160px, 1.4fr) minmax(92px, 110px) auto;
  gap: 8px;
  align-items: center;
}

.logs-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.logs-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 330px);
  min-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fbfdff;
}

.log-item {
  display: grid;
  gap: 8px;
  border: 1px solid #e4ebef;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  box-shadow: 0 6px 14px rgba(20, 34, 45, 0.035);
}

.log-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
}

.log-title {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.log-title strong {
  direction: ltr;
  text-align: right;
  word-break: break-word;
}

.log-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  background: #edf4f6;
  color: #203240;
}

.log-badge.error { background: #fff1f2; color: #9f1239; }
.log-badge.warn { background: #fffbeb; color: #92400e; }
.log-badge.info { background: #ecfdf5; color: #065f46; }

.log-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 6px;
  font-size: 13px;
  color: #344552;
}

.log-summary span {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.log-details summary {
  cursor: pointer;
  color: var(--accent-2);
  font-weight: 800;
  width: fit-content;
}

.log-details pre {
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
  max-height: 260px;
  margin: 8px 0 0;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #dce7ec;
  background: #f8fbfc;
  color: #344552;
  font-size: 12px;
}

textarea { width: 100%; min-height: 180px; resize: vertical; direction: ltr; text-align: left; }

.internal-notes-panel textarea {
  min-height: 110px;
  direction: rtl;
  text-align: right;
}

textarea.channel-prompt {
  min-height: 92px;
  font-size: 13px;
  line-height: 1.45;
}

.prompt-sections {
  display: grid;
  gap: 14px;
}

.prompt-group {
  display: grid;
  gap: 10px;
}

.prompt-group-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 8px 0 2px;
  border-bottom: 1px solid #edf1f4;
}

.prompt-group-title h3 {
  font-size: 17px;
  margin: 0;
}

.prompt-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  display: grid;
  gap: 12px;
  box-shadow: 0 6px 16px rgba(20, 34, 45, 0.04);
}

.prompt-section textarea {
  min-height: 150px;
  line-height: 1.45;
}

.fixed-contract pre {
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  overflow: auto;
  max-height: 340px;
  margin: 10px 0 0;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #dce7ec;
  background: #f8fbfc;
  color: #344552;
  font-size: 12px;
}

.knowledge-template {
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #dce7ec;
  background: #f8fbfc;
  color: #344552;
  font-size: 12px;
}

.vector-call-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.vector-call-grid > div {
  padding: 12px;
  border: 1px solid #dce7ec;
  border-radius: 8px;
  background: #f8fbfc;
}

.vector-call-grid p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.vector-flow {
  margin: 0;
  padding-inline-start: 22px;
  line-height: 1.7;
}

.media-upload-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.media-upload-grid textarea {
  min-height: 82px;
  direction: rtl;
  text-align: right;
}

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

.media-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  display: grid;
  grid-template-columns: 140px 1fr auto;
  gap: 12px;
  align-items: start;
  box-shadow: 0 6px 16px rgba(20, 34, 45, 0.04);
}

.media-preview {
  min-width: 0;
  border: 1px solid #dce7ec;
  border-radius: 8px;
  background: #f8fbfc;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.media-preview img,
.media-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.media-preview audio {
  width: 92%;
}

.media-body {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.media-body textarea {
  min-height: 78px;
  direction: rtl;
  text-align: right;
}

.media-url {
  direction: ltr;
  text-align: left;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.media-actions {
  display: grid;
  gap: 8px;
  min-width: 104px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.section-intro {
  display: grid;
  gap: 6px;
  max-width: 880px;
}

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

.settings-sections {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: start;
}

.settings-group-heading {
  grid-column: 1 / -1;
  padding: 8px 2px 0;
  border-top: 1px solid #dfe8ec;
  display: grid;
  gap: 3px;
}

.settings-group-heading:first-child {
  border-top: 0;
  padding-top: 0;
}

.settings-group-heading h3 {
  font-size: 15px;
  margin: 0;
}

.settings-group-heading .tiny {
  line-height: 1.4;
}

.settings-group-technical { order: 10; }
