:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #18202c;
  --muted: #667386;
  --line: #dbe3eb;
  --primary: #16657f;
  --primary-dark: #0d475b;
  --accent: #b45309;
  --danger: #b42318;
  --ok: #167449;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  align-items: center;
  background: #102531;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  min-height: 60px;
  padding: 0 28px;
}

.brand {
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
}

.topbar nav {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: flex-end;
}

.topbar nav a { color: #e8f1f4; }

.wrap {
  margin: 0 auto;
  max-width: 1880px;
  padding: 24px 32px;
}

h1, h2, p { margin-top: 0; }
h1 { font-size: 30px; letter-spacing: 0; }
h2 { font-size: 18px; letter-spacing: 0; }
.muted { color: var(--muted); }
.eyebrow { color: var(--primary); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

.hero, .page-title, .contact-head {
  align-items: flex-start;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 22px;
}

.hero {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 24px;
}

.hero p:last-child { margin-bottom: 0; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button, .button {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 700;
  justify-content: center;
  min-height: 38px;
  padding: 8px 13px;
}

.danger-button {
  background: #fff;
  border-color: #f3b6b0;
  color: var(--danger);
}

.danger-button:hover {
  background: #fff1f0;
}

.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.primary:hover {
  background: var(--primary-dark);
  text-decoration: none;
}

input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  min-height: 38px;
  padding: 8px 10px;
  width: 100%;
}

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

label {
  color: #334155;
  display: grid;
  font-weight: 700;
  gap: 7px;
}

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

.checkbox-line input {
  min-height: 0;
  width: auto;
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  margin: 11vh auto 0;
  max-width: 430px;
  padding: 30px;
}

.form { display: grid; gap: 14px; }
.alert { background: #fff1f0; border: 1px solid #ffccc7; color: var(--danger); margin: 14px 0; padding: 12px; }

.quick-form {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: 190px 190px minmax(260px, 1fr) 120px;
}

.quick-note {
  min-width: 0;
}

.cards {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-bottom: 20px;
}

.metric, .panel, .table-card {
  background: var(--panel);
  border: 1px solid var(--line);
}

.metric { padding: 16px; }
.metric span { color: var(--muted); display: block; font-size: 13px; }
.metric strong { display: block; font-size: 28px; margin-top: 6px; }

.split {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, .8fr);
  margin-bottom: 18px;
}

.detail-bottom-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  margin-bottom: 18px;
}

.panel { padding: 18px; }
.panel.narrow { max-width: 540px; }
.quote-panel p:last-child { margin-bottom: 0; }
.quote-panel details {
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 10px;
}
.quote-panel summary {
  color: var(--primary);
  cursor: pointer;
  font-weight: 700;
}
.panel-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

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

.pipeline-mini a {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  padding: 12px;
}

.pipeline-mini strong { font-size: 22px; }

.saved-views {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.saved-views a, .chips a, .tool-list a {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  padding: 7px 11px;
}

.saved-select {
  appearance: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  font-weight: 400;
  min-height: 34px;
  padding: 6px 10px;
  width: 190px;
}

.saved-select.operative-select {
  width: 240px;
}

.filters {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(280px, 1fr) 90px 110px;
  margin-bottom: 16px;
}

.filter-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  margin-bottom: 16px;
  padding: 12px;
}

.filter-row {
  align-items: center;
  display: grid;
  gap: 10px;
}

.primary-filter-row {
  grid-template-columns: minmax(320px, 1fr) 240px 190px;
}

.secondary-filter-row {
  grid-template-columns: repeat(4, minmax(150px, 190px)) 90px 110px;
  margin-top: 10px;
}

.filter-search {
  min-width: 0;
}

.bulk-delete {
  margin-bottom: 16px;
}

.bulk-bar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 10px;
}

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

.bulk-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.result-count {
  align-items: baseline;
  color: var(--text);
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.result-count strong {
  font-size: 22px;
}

.table-card { overflow-x: auto; }
table {
  border-collapse: collapse;
  min-width: 1480px;
  table-layout: fixed;
  width: 100%;
}

.companies-table {
  min-width: 1620px;
}

.col-select { width: 44px; }
.col-company { width: 280px; }
.col-contacts { width: 340px; }
.col-email { width: 330px; }
.col-segment { width: 190px; }
.col-origin { width: 190px; }
.col-quote { width: 120px; }
.col-orders { width: 100px; }
.col-news { width: 250px; }

th, td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; vertical-align: top; }
th { color: #526073; font-size: 12px; text-transform: uppercase; }
th > span {
  display: block;
  margin-bottom: 6px;
}
td span { color: var(--muted); display: block; font-size: 13px; margin-top: 4px; }

.table-filter-select {
  appearance: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  min-height: 30px;
  padding: 4px 8px;
  text-transform: none;
  width: 100%;
}

.table-filter-pair {
  display: grid;
  gap: 5px;
}

.select-col {
  min-width: 46px;
  text-align: center;
  width: 46px;
}

.select-col input {
  min-height: 0;
  width: auto;
}

.num-col {
  color: var(--muted);
  font-weight: 700;
  text-align: right;
}

.company-cell {
  min-width: 0;
}

.company-cell strong {
  display: block;
  font-size: 14px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-cell a:hover {
  text-decoration: none;
}

.contacts-stack {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.person-line {
  border-bottom: 1px solid #edf2f7;
  display: grid;
  gap: 2px;
  overflow-wrap: anywhere;
  padding-bottom: 8px;
}

.person-line:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.person-line a {
  font-size: 13px;
  font-weight: 700;
  margin-top: 2px;
}

.small-line {
  min-height: 40px;
}

.small-line strong {
  font-size: 13px;
}

.phone-stack {
  min-width: 160px;
}

.phone-line {
  white-space: nowrap;
}

.phone-line strong {
  font-size: 12px;
  letter-spacing: 0;
}

.quick {
  display: grid;
  gap: 7px;
  grid-template-columns: 155px 150px minmax(180px, 1fr) 145px 48px;
  min-width: 680px;
}

.quick-min {
  grid-template-columns: 140px 110px 145px minmax(160px, 1fr) 48px;
  min-width: 650px;
}

.date { color: var(--accent); display: inline; margin-right: 5px; }

.pill {
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 6px 9px;
}

.revisar { background: #64748b; }
.preparar_borrador { background: #7c3aed; }
.contactar { background: #16657f; }
.esperando_respuesta { background: #b45309; }
.interesado { background: #167449; }
.no_contactar { background: #9f1239; }
.cerrado { background: #475569; }

.rel {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 9px;
  white-space: normal;
}

.rel.cliente {
  background: #e8f7ef;
  border-color: #b7e2ca;
  color: #12633d;
}

.rel.no_cliente {
  background: #eef3f7;
  border-color: #d4dde7;
  color: #445266;
}

.rel.presupuesto {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #9a4a08;
}

.rel.interesado {
  background: #ecfdf5;
  border-color: #bbf7d0;
  color: #166534;
}

.rel.prl {
  background: #eef6ff;
  border-color: #bfdbfe;
  color: #1d4f8c;
}

.rel.pendiente_clasificar {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #9a4a08;
}

.status {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 9px;
  white-space: nowrap;
}

.status-prospecto { background: #eef2f7; color: #455468; }
.status-contactado { background: #e8f3fb; color: #185a82; }
.status-interesado { background: #e8f7ef; color: #12633d; }
.status-cliente { background: #dcfce7; color: #166534; }
.status-dormido { background: #fff7ed; color: #9a4a08; }
.status-perdido { background: #fff1f2; color: #9f1239; }
.rel.cliente { background: #e8f7ef; border-color: #b7e2ca; color: #12633d; }

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

.pipe-col {
  background: #eef3f6;
  border: 1px solid var(--line);
  min-height: 420px;
  padding: 12px;
}

.pipe-col h2 {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.pipe-col h2 span { color: var(--muted); font-size: 14px; }

.deal {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  display: block;
  margin-bottom: 10px;
  padding: 12px;
}

.deal span { color: var(--muted); display: block; font-size: 12px; margin-top: 4px; }
.deal p { color: #334155; font-size: 13px; margin: 8px 0 0; }

.contact-head {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 22px;
}

.contact-head h1 { margin-bottom: 6px; }
.contact-head p { color: var(--muted); margin-bottom: 0; overflow-wrap: anywhere; }

.contact-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 10px;
}

.contact-meta a,
.contact-meta span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.contact-meta a {
  color: var(--primary);
  font-weight: 700;
}

.company-people {
  margin-bottom: 18px;
}

.company-news {
  margin-bottom: 18px;
}

.follow-up-panel,
.notes-panel,
.tasks-panel {
  margin-bottom: 0;
}

.follow-up-panel,
.notes-panel {
  align-self: start;
}

.order-summary-panel,
.history-panel {
  margin-bottom: 18px;
}

.company-people-list {
  display: grid;
  gap: 8px;
}

.company-person-row {
  align-items: start;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(180px, .8fr) minmax(220px, 1fr) minmax(240px, 1.2fr) auto;
  padding: 11px 0;
}

.company-person-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.company-person-row strong,
.company-person-row a {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.company-person-row span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.company-person-row small {
  color: var(--muted);
  display: block;
  font-size: 12px;
  line-height: 1.35;
  margin-top: 6px;
}

.company-person-row.is-inactive {
  opacity: .68;
}

.contact-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.company-person-row .contact-flag {
  border-radius: 999px;
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  margin-top: 0;
  padding: 3px 7px;
}

.primary-flag {
  background: #e8f7ef;
  color: #12633d !important;
}

.inactive-flag {
  background: #eef2f7;
  color: #455468 !important;
}

.contact-methods {
  display: grid;
  gap: 4px;
}

.company-person-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
}

.company-person-actions form {
  margin: 0;
}

.small-button {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

.company-news-list {
  display: grid;
  gap: 8px;
}

.company-news-row {
  align-items: start;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
  grid-template-columns: 110px minmax(0, 1fr) auto;
  padding: 11px 0;
}

.company-news-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.company-news-row time,
.company-news-row span {
  color: var(--muted);
  font-size: 13px;
}

.company-news-row strong {
  display: block;
  overflow-wrap: anywhere;
}

.news-state {
  background: #e8f7ef;
  border-radius: 999px;
  color: #12633d !important;
  font-weight: 800;
  padding: 5px 9px;
}

.grid-form {
  background: var(--panel);
  border: 1px solid var(--line);
  display: grid;
  gap: 15px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 20px;
}

.simple-edit {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 980px;
}

.form-section-title {
  border-top: 1px solid var(--line);
  color: var(--primary);
  font-size: 15px;
  grid-column: 1 / -1;
  margin: 8px 0 0;
  padding-top: 16px;
}

.form-section-title:first-of-type {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

.wide { grid-column: 1 / -1; }

.timeline { display: grid; gap: 10px; }
.timeline article {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 4px;
  padding: 10px 0 0;
}
.timeline article:first-child { border-top: 0; padding-top: 0; }
.timeline time, .timeline span { color: var(--muted); font-size: 13px; }

.task {
  align-items: start;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: 38px 1fr;
  padding: 10px 0;
}
.task:first-of-type { border-top: 0; }
.task.cerrada { opacity: .55; }
.task button { min-height: 30px; padding: 0; }
.task span { color: var(--muted); display: block; font-size: 13px; margin-top: 4px; }

.order-form {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: 150px minmax(220px, 1fr) 140px minmax(180px, 1fr) auto;
  margin-bottom: 18px;
}

.orders-list {
  display: grid;
  gap: 12px;
}

.order-card {
  align-items: start;
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) 130px;
  padding: 14px;
}

.order-main {
  display: grid;
  gap: 14px;
  grid-template-columns: 95px minmax(0, 1fr);
}

.order-date {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.order-copy {
  min-width: 0;
}

.order-copy strong {
  display: block;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.order-copy p {
  color: #334155;
  margin: 5px 0 0;
  overflow-wrap: anywhere;
}

.order-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  margin-top: 8px;
}

.order-meta span,
.pdf-missing {
  color: var(--muted);
  font-size: 13px;
}

.order-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 10px;
}

.small-button {
  font-size: 13px;
  min-height: 30px;
  padding: 5px 10px;
}

.order-actions details {
  color: var(--primary);
  font-size: 13px;
}

.order-actions summary {
  cursor: pointer;
  font-weight: 700;
}

.order-detail {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  margin-top: 8px;
  max-width: 760px;
  padding: 10px;
}

.order-detail p {
  color: var(--text);
  font-size: 13px;
  margin: 0 0 8px;
}

.order-detail p:last-child { margin-bottom: 0; }

.order-amount {
  color: #12633d;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.order-total {
  align-items: center;
  border-top: 2px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  padding-top: 14px;
}

.order-total span { color: var(--muted); }
.order-total strong { color: #12633d; font-size: 18px; }

.history-day-group {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

.history-day-group:first-of-type {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

.history-day {
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .04em;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.history-entry-list {
  display: grid;
  gap: 12px;
}

.history-entry {
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.history-entry-head {
  align-items: start;
  display: flex;
  gap: 14px;
  justify-content: space-between;
}

.history-entry-head strong {
  display: block;
  font-size: 15px;
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}

.history-entry-head time,
.history-person,
.history-entry-meta span,
.history-entry-meta a {
  color: var(--muted);
  font-size: 13px;
}

.history-person {
  display: block;
}

.history-entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 10px;
}

.history-entry-body {
  color: #334155;
  line-height: 1.55;
  margin-top: 10px;
  overflow-wrap: anywhere;
}

.notes-panel p {
  color: #334155;
  line-height: 1.6;
  margin-bottom: 0;
  white-space: pre-wrap;
}

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

.news-summary {
  margin-bottom: 18px;
}

.news-summary .chips span {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  display: inline-flex;
  font-weight: 700;
  padding: 7px 11px;
}

.news-table {
  min-width: 1280px;
}

.news-badge,
.news-rec {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  gap: 5px;
  line-height: 1;
  padding: 6px 9px;
  white-space: nowrap;
}

.news-badge span {
  color: inherit;
  display: inline;
  font-size: 11px;
  margin: 0;
}

.news-yes {
  background: #e8f7ef;
  color: #12633d;
}

.news-no {
  background: #fff1f2;
  color: #9f1239;
}

.news-mini-list {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.news-mini {
  border-radius: 999px;
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  padding: 6px 8px;
  white-space: nowrap;
}

.news-rec {
  background: #fff7ed;
  color: #9a4a08;
}

.news-rec.mundial_2026,
.news-rec.eclipse_agosto,
.news-rec.polarbox {
  background: #e8f3fb;
  color: #185a82;
}

.news-rec.esperar {
  background: #fff7ed;
  color: #9a4a08;
}

.news-rec.excluido {
  background: #fff1f2;
  color: #9f1239;
}

.news-rec.completo {
  background: #e8f7ef;
  color: #12633d;
}

.chips, .tool-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(3, 1fr); }
  .split, .detail-bottom-grid, .filters, .grid-form, .order-form, .quick-form, .primary-filter-row, .secondary-filter-row, .company-person-row, .company-news-row { grid-template-columns: 1fr; }
  .order-card, .order-main { grid-template-columns: 1fr; }
  .order-amount { text-align: left; }
  .quick { grid-template-columns: 1fr; min-width: 260px; }
}

@media (max-width: 720px) {
  .wrap { padding: 16px; }
  .topbar, .hero, .page-title, .contact-head { align-items: stretch; flex-direction: column; }
  .topbar nav { justify-content: flex-start; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  h1 { font-size: 24px; }
  .history-entry-head { flex-direction: column; }
}
