:root {
  --bg: #070807;
  --bg2: #0d0f0d;
  --bg3: #131613;
  --surface: #101210;
  --text: #eef2ee;
  --muted: #7d8a7d;
  --omb: #14a237;
  --omb-2: #0f8a2c;
  --omb-soft: rgba(20, 162, 55, 0.12);
  --line: rgba(255, 255, 255, 0.06);
  --line-strong: rgba(20, 162, 55, 0.35);
  --verde: #14a237;
  --amarillo: #c9a227;
  --rojo: #db4a3f;
  --danger: #b33a32;
  --radius: 14px;
  --font: "Sora", "Segoe UI", sans-serif;
  --display: "Sora", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(20, 162, 55, 0.12), transparent 55%),
    radial-gradient(700px 400px at 100% 0%, rgba(20, 162, 55, 0.06), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--omb); text-decoration: none; }
a:hover { color: #22c55e; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--text) !important;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
}
.brand img { height: 26px; width: auto; display: block; }
.brand em {
  font-style: normal;
  color: var(--omb);
  font-weight: 700;
}
.topbar nav {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}
.topbar nav a {
  color: var(--muted);
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
}
.topbar nav a:hover {
  color: var(--text);
  background: var(--omb-soft);
}

.wrap { width: min(1080px, calc(100% - 2rem)); margin: 0 auto; padding: 1.5rem 0 2.5rem; }
.wrap-wide { width: min(1540px, calc(100% - 1.5rem)); margin: 0 auto; padding: 1rem 0 1.5rem; }

.page-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.page-title h1 {
  margin: 0;
  font-size: clamp(1.5rem, 2vw, 1.85rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}
.page-title p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

/* Todos los botones van en verde OMB (nada de azul del navegador) */
button,
.btn,
input[type="submit"],
input[type="button"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background: var(--omb) !important;
  color: #041208 !important;
  border: 1px solid var(--omb) !important;
  border-radius: 999px;
  padding: 0.62rem 1.15rem;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none !important;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}
button:hover,
.btn:hover,
input[type="submit"]:hover {
  background: #1bb844 !important;
  border-color: #1bb844 !important;
}
button:active,
.btn:active { transform: translateY(1px); }
.btn.secondary,
button.secondary {
  background: transparent !important;
  color: var(--omb) !important;
  border: 1px solid var(--omb) !important;
}
.btn.secondary:hover,
button.secondary:hover {
  background: var(--omb-soft) !important;
  color: #1bb844 !important;
  border-color: #1bb844 !important;
}
.btn.danger,
button.danger {
  background: var(--danger) !important;
  border-color: var(--danger) !important;
  color: #fff !important;
}
.btn.small,
button.small { padding: 0.38rem 0.8rem; font-size: 0.8rem; }
.btn.block { width: 100%; }

/* Autofill del navegador (a veces pinta azul/amarillo) */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px #0a0c0a inset;
  transition: background-color 9999s ease-in-out 0s;
  caret-color: var(--text);
}

input, select, textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.45);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--omb);
  box-shadow: 0 0 0 3px var(--omb-soft);
}
label {
  display: block;
  margin: 0.7rem 0 0.3rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.meta { color: var(--muted); font-size: 0.86rem; }
.error {
  color: #ffb4ae;
  background: rgba(219, 74, 63, 0.12);
  border: 1px solid rgba(219, 74, 63, 0.3);
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  margin: 0.75rem 0;
  font-size: 0.9rem;
}

/* —— Login —— */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  position: relative;
  overflow: hidden;
}
.login-screen::before {
  content: "";
  position: absolute;
  inset: auto -20% -30% -20%;
  height: 55%;
  background: radial-gradient(ellipse at center, rgba(20, 162, 55, 0.18), transparent 70%);
  pointer-events: none;
}
.login-panel {
  width: min(420px, 100%);
  position: relative;
  z-index: 1;
  padding: 2rem 1.75rem 1.75rem;
  background: linear-gradient(180deg, #0f120f 0%, #0a0c0a 100%);
  border: 1px solid var(--line);
  border-radius: 22px;
}
.login-panel .logo {
  display: block;
  height: 48px;
  width: auto;
  margin: 0 auto 1.25rem;
}
.login-panel h1 {
  margin: 0;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.login-panel .sub {
  text-align: center;
  color: var(--muted);
  margin: 0.4rem 0 1.4rem;
  font-size: 0.9rem;
}
.login-panel .btn { margin-top: 1.15rem; }

/* —— Lista clientes —— */
.filters {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: end;
}
.client-list {
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.28);
}
.client-row {
  display: grid;
  grid-template-columns: 18px 1.4fr 1fr 0.8fr 0.55fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.95rem 1.1rem;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none !important;
  transition: background 0.15s ease;
}
.client-row:last-child { border-bottom: none; }
.client-row:hover { background: var(--omb-soft); }
.client-row .name {
  color: var(--text);
  font-weight: 600;
  font-size: 0.98rem;
}
.client-row .cell { color: var(--muted); font-size: 0.88rem; }
.client-row .dias.warn { color: var(--rojo); font-weight: 700; }
.client-head {
  display: grid;
  grid-template-columns: 18px 1.4fr 1fr 0.8fr 0.55fr auto;
  gap: 0.75rem;
  padding: 0.65rem 1.1rem;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
}
.empty {
  padding: 2rem 1.1rem;
  color: var(--muted);
  text-align: center;
}

.dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  display: inline-block;
}
.dot.verde { background: var(--verde); box-shadow: 0 0 0 3px rgba(20, 162, 55, 0.18); }
.dot.amarillo { background: var(--amarillo); box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.18); }
.dot.rojo { background: var(--rojo); box-shadow: 0 0 0 3px rgba(219, 74, 63, 0.18); }

/* —— Ficha —— */
.ficha-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1rem;
}
.ficha-head h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 1.7rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.ficha-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.ficha-main {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(420px, 1.2fr);
  gap: 0.9rem;
  min-height: calc(100vh - 150px);
  align-items: stretch;
}
.panel {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
}
.panel-head h2 {
  margin: 0;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--omb);
  font-weight: 700;
}
.panel-body {
  padding: 1rem 1.1rem;
  overflow: auto;
  flex: 1;
  min-height: 0;
}

.resumen-box {
  white-space: pre-wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.05rem 1.15rem;
  font-size: 0.94rem;
  line-height: 1.6;
  max-height: 44vh;
  overflow: auto;
}

.chip-row { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.76rem;
  text-decoration: none !important;
}
.chip:hover, .chip.active {
  border-color: var(--line-strong);
  color: var(--omb);
  background: var(--omb-soft);
}

details.compact {
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-top: 0.75rem;
  background: rgba(0, 0, 0, 0.25);
}
details.compact > summary {
  cursor: pointer;
  padding: 0.7rem 0.9rem;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  list-style: none;
}
details.compact > summary::-webkit-details-marker { display: none; }
details.compact > summary::after { content: " +"; color: var(--omb); float: right; }
details.compact[open] > summary::after { content: " −"; }
details.compact[open] > summary {
  border-bottom: 1px solid var(--line);
  color: var(--text);
}
details.compact .inner { padding: 0.8rem 0.9rem 1rem; }

.tl-item {
  border-left: 2px solid rgba(20, 162, 55, 0.45);
  padding: 0.4rem 0 0.4rem 0.8rem;
  margin-bottom: 0.45rem;
}
.tl-item .tag {
  display: inline-block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--omb);
  margin-bottom: 0.1rem;
}

.chat-panel .panel-body { padding: 0; display: flex; flex-direction: column; }
.chat-box {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: calc(100vh - 175px);
}
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.bubble {
  padding: 0.8rem 0.95rem;
  border-radius: 16px;
  white-space: pre-wrap;
  max-width: 92%;
  font-size: 0.94rem;
  line-height: 1.55;
}
.bubble.user {
  align-self: flex-end;
  background: var(--omb-soft);
  border: 1px solid var(--line-strong);
  border-bottom-right-radius: 6px;
}
.bubble.assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}
.chat-compose {
  border-top: 1px solid var(--line);
  padding: 0.9rem 1rem 1rem;
  background: rgba(0, 0, 0, 0.4);
}
.chat-compose textarea {
  min-height: 92px;
  resize: vertical;
  margin-bottom: 0.55rem;
}
.chat-compose .row {
  display: flex;
  justify-content: flex-end;
}

.surface-card {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.15rem;
}

@media (max-width: 980px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .client-head { display: none; }
  .client-row {
    grid-template-columns: 18px 1fr auto;
    grid-template-areas:
      "dot name edit"
      "dot meta edit"
      "dot dias edit";
  }
  .client-row .name { grid-area: name; }
  .client-row .tier, .client-row .estado { display: none; }
  .client-row .dias { grid-area: dias; }
  .ficha-main { grid-template-columns: 1fr; min-height: auto; }
  .chat-box { min-height: 58vh; }
  .resumen-box { max-height: none; }
  .form-grid { grid-template-columns: 1fr; }
}
