:root {
  --bg: #f3efe6;
  --bg-2: #ebe4d6;
  --ink: #1c2430;
  --muted: #5c6675;
  --line: #d5cdb8;
  --card: #fffcf5;
  --accent: #0f5c4c;
  --accent-2: #c45c26;
  --accent-soft: #d8ebe5;
  --danger: #9b2c2c;
  --shadow: 0 10px 30px rgba(28, 36, 48, 0.08);
  --radius: 18px;
  --font: "Source Serif 4", Georgia, serif;
  --sans: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, #e7f2ee 0%, transparent 40%),
    radial-gradient(circle at 100% 20%, #f6e7dc 0%, transparent 35%),
    var(--bg);
  font-family: var(--sans);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); }

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 18px 80px;
}

.hero {
  display: grid;
  gap: 10px;
  margin-bottom: 22px;
  padding: 28px 24px;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  background: linear-gradient(160deg, #fffaf0, #f2ebe0);
  box-shadow: var(--shadow);
}
.hero h1 {
  margin: 0;
  font-family: var(--font);
  font-weight: 600;
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  letter-spacing: -0.02em;
}
.hero p { margin: 0; color: var(--muted); max-width: 55ch; }
.badge-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.badge {
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid #b7d7cd;
}

.nav {
  position: sticky;
  top: 10px;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  margin-bottom: 18px;
  background: rgba(255, 252, 245, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.nav button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
.nav button.active {
  background: var(--accent);
  color: #fff;
}

.panel { display: none; }
.panel.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 16px;
}
.section-head h2 {
  margin: 0;
  font-family: var(--font);
  font-size: 1.55rem;
}
.section-head p { margin: 4px 0 0; color: var(--muted); font-size: 0.95rem; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
select, input[type="password"], input[type="text"], textarea {
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
select { min-width: 160px; }

.btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: #efe7d8; color: var(--ink); }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}
th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  background: var(--bg-2);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
td.unit {
  white-space: nowrap;
  font-weight: 700;
  color: var(--accent);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
@media (max-width: 800px) {
  .grid-2 { grid-template-columns: 1fr; }
  .nav { border-radius: 18px; }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card h3 {
  margin: 0 0 8px;
  font-family: var(--font);
  font-size: 1.15rem;
}
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: #efe7d8;
  color: var(--muted);
}
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.warn { background: #f6e0d4; color: var(--accent-2); }

.flash {
  min-height: 280px;
  display: grid;
  align-content: space-between;
  gap: 16px;
}
.flash .q {
  font-family: var(--font);
  font-size: clamp(1.2rem, 2.5vw, 1.55rem);
  line-height: 1.35;
}
.flash .a {
  padding: 14px;
  border-radius: 14px;
  background: #f4faf7;
  border: 1px solid #c5ddd4;
}
.flash .hidden-a { display: none; }
.flash-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.author-card p { margin: 0; color: var(--ink); }
.author-card .name {
  font-family: var(--font);
  font-size: 1.1rem;
  margin-bottom: 6px;
}

.consigna {
  border-left: 4px solid var(--accent-2);
  padding-left: 12px;
  margin: 0;
}

.chat-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 14px;
}
@media (max-width: 900px) {
  .chat-layout { grid-template-columns: 1fr; }
}

.chat-settings label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  margin: 10px 0 6px;
  color: var(--muted);
}
.chat-settings input, .chat-settings textarea { width: 100%; }
.hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 10px;
}
.hint.warn { color: var(--danger); }

.chat-box {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 520px;
}
.messages {
  overflow: auto;
  max-height: 480px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px;
  margin-bottom: 12px;
}
.msg {
  max-width: 92%;
  padding: 12px 14px;
  border-radius: 16px;
  white-space: pre-wrap;
  line-height: 1.45;
}
.msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.msg.bot {
  align-self: flex-start;
  background: #f4faf7;
  border: 1px solid #c5ddd4;
  border-bottom-left-radius: 6px;
}
.msg.system {
  align-self: center;
  background: #efe7d8;
  color: var(--muted);
  font-size: 0.88rem;
  max-width: 100%;
}
.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.composer textarea {
  resize: vertical;
  min-height: 70px;
}
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  background: #999;
}
.status-dot.ok { background: #1f8a5a; }
.status-dot.bad { background: var(--danger); }
.status-dot.wait { background: #d4a017; }

.footer-note {
  margin-top: 28px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.side-hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}

.doc-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: grid;
  gap: 6px;
}
.doc-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  font-size: 0.82rem;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
}
.doc-list li span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-list li.doc-default {
  background: color-mix(in srgb, var(--accent, #2d6a4f) 12%, var(--bg-2));
}
.doc-list .doc-meta {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  opacity: 0.75;
  white-space: nowrap;
}
.doc-list button {
  border: 0;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font-weight: 700;
  flex-shrink: 0;
}
input[type="file"] {
  width: 100%;
  font-size: 0.82rem;
}
