:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #1d4ed8;
    --primary-dark: #1e3a8a;
    --line: #dbe4f0;
    --ok-bg: #dcfce7;
    --ok: #166534;
    --warn-bg: #fef3c7;
    --warn: #92400e;
    --error-bg: #fee2e2;
    --error: #991b1b;
    --soft: #eff6ff;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}
.hero {
    padding: 42px 24px;
    color: white;
    background: radial-gradient(circle at top left, #2563eb, #0f172a 65%);
}
.hero > div, .container { max-width: 1240px; margin: 0 auto; }
h1, h2, h3 { margin: 0 0 10px; letter-spacing: -0.03em; }
h1 { font-size: clamp(2rem, 4vw, 3.35rem); }
h2 { font-size: clamp(1.4rem, 2vw, 2rem); }
h3 { font-size: 1.2rem; }
p { line-height: 1.6; }
.eyebrow {
    margin: 0 0 8px;
    text-transform: uppercase;
    letter-spacing: .14em;
    font-weight: 800;
    font-size: .78rem;
    color: #60a5fa;
}
.hero .eyebrow { color: #93c5fd; }
.container { padding: 28px 20px 60px; }
.grid { display: grid; gap: 14px; }
.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 20px; }
.metrics-five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.metric-card, .panel, .builder-card, .index-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: 0 14px 32px rgba(15, 23, 42, .06);
}
.metric-card { padding: 18px; min-width: 0; }
.metric-card span, .plan span { display: block; color: var(--muted); font-size: .82rem; }
.metric-card strong { display: block; margin-top: 7px; font-size: 1.4rem; overflow-wrap: anywhere; }
.metric-card small { display: block; margin-top: 7px; color: var(--muted); }
.panel { padding: 24px; margin-top: 20px; }
.panel-heading { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
button, .button-link {
    border: 0;
    border-radius: 999px;
    background: var(--primary);
    color: white;
    font-weight: 800;
    padding: 11px 16px;
    cursor: pointer;
    font: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
button:hover, .button-link:hover { background: var(--primary-dark); }
button.secondary, .secondary-link { background: #334155; }
button.ghost { background: #e2e8f0; color: #334155; }
button.danger { background: #b91c1c; }
button.danger:hover { background: #991b1b; }
.small-button { padding: 7px 11px; font-size: .78rem; }
label { display: grid; gap: 6px; color: var(--muted); font-weight: 700; }
select, input {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 10px 12px;
    font: inherit;
    background: white;
    color: var(--text);
}
.index-builders { display: grid; grid-template-columns: 1fr 1.3fr; gap: 14px; margin-bottom: 18px; }
.builder-card { padding: 18px; display: grid; gap: 14px; box-shadow: none; }
.builder-card > div:first-child { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.step-label { color: var(--primary); font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; font-weight: 900; }
.compound-selects { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.index-preview { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px; border-radius: 14px; background: var(--soft); }
.index-preview span, .index-path span { padding: 6px 10px; border-radius: 999px; background: white; border: 1px solid #bfdbfe; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.index-visual-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin: 18px 0; }
.index-card { padding: 16px; box-shadow: none; }
.index-card.automatic { background: #f8fafc; }
.index-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.index-card-head span { color: var(--muted); font-size: .78rem; }
.index-card-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.index-card-actions form { margin: 0; }
.index-path { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 14px 0; }
.size-row { display: flex; justify-content: flex-end; color: var(--muted); }
.size-bar { height: 7px; border-radius: 999px; background: #e2e8f0; overflow: hidden; margin-top: 5px; }
.size-bar i { display: block; height: 100%; background: var(--primary); border-radius: inherit; }
.prefix-note { display: block; color: var(--muted); line-height: 1.45; margin-top: 10px; }
.query-builder { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.query-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.compact-table { margin-top: 12px; }
code, pre { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace; }
.query-box {
    background: #0f172a;
    color: #dbeafe;
    border-radius: 16px;
    padding: 16px;
    margin: 18px 0 10px;
    overflow-x: auto;
}
.explain-note { background: #eef2ff; border: 1px solid #c7d2fe; padding: 12px 14px; border-radius: 14px; color: #3730a3; margin-bottom: 14px; }
.plan {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
    padding: 13px;
    border-radius: 18px;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
}
.plan > div { background: white; border-radius: 14px; padding: 12px; border: 1px solid var(--line); min-width: 0; }
.plan strong { display: block; margin-top: 6px; font-size: .96rem; overflow-wrap: anywhere; }
.plan.ok { background: var(--ok-bg); border-color: #86efac; }
.plan.warn { background: var(--warn-bg); border-color: #fbbf24; }
.hint, .muted { color: var(--muted); }
.alert { padding: 16px 20px; border-radius: 18px; margin-bottom: 18px; }
.alert.success { background: var(--ok-bg); color: var(--ok); }
.alert.error { background: var(--error-bg); color: var(--error); }
.raw-explain { margin: 14px 0 22px; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: #f8fafc; }
.raw-explain summary { cursor: pointer; font-weight: 800; }
.raw-explain pre { max-height: 360px; overflow: auto; background: #0f172a; color: #e2e8f0; padding: 14px; border-radius: 12px; white-space: pre-wrap; }
.section-title { margin-top: 22px; }
.compare-table th:nth-child(2), .compare-table td:nth-child(2) { background: #fffbeb; }
.compare-table th:nth-child(3), .compare-table td:nth-child(3) { background: #f0fdf4; }
.write-flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; gap: 10px; align-items: center; margin: 12px 0; }
.write-flow > div { padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #f8fafc; }
.write-flow strong, .write-flow span { display: block; }
.write-flow span { color: var(--muted); margin-top: 4px; font-size: .88rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
ul { margin-bottom: 0; }
li { margin: 8px 0; line-height: 1.5; }
.code-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 18px 0; }
.code-compare > div { background: #0f172a; color: white; border-radius: 16px; overflow: hidden; }
.code-compare span { display: block; padding: 10px 14px; background: #1e293b; color: #93c5fd; font-weight: 800; }
.code-compare pre { margin: 0; padding: 16px; overflow-x: auto; color: #e2e8f0; }
@media (max-width: 1050px) {
    .metrics-five { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .query-builder { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .plan { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .metrics, .metrics-five, .index-builders, .two-col, .code-compare, .query-builder, .compound-selects, .plan { grid-template-columns: 1fr; }
    .panel-heading { flex-direction: column; }
    .actions { justify-content: flex-start; }
    .write-flow { grid-template-columns: 1fr; }
    .write-flow > b { text-align: center; }
}

/* V3: estados, formularios de escritura y ayudas de exposición */
.metrics-six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.metric-card.metric-ok { border-color: #86efac; background: #f0fdf4; }
.metric-card.metric-error { border-color: #fecaca; background: #fef2f2; }
.alert.info { background: #e0f2fe; color: #075985; }
.empty-state {
    border: 1px dashed #94a3b8;
    border-radius: 16px;
    padding: 22px;
    display: grid;
    gap: 6px;
    color: #475569;
    background: #f8fafc;
}
.empty-state strong { color: var(--text); }
.command-preview {
    display: block;
    padding: 10px 12px;
    border-radius: 12px;
    background: #0f172a;
    color: #dbeafe;
    overflow-x: auto;
    white-space: nowrap;
}
.invalid-builder { border-color: #fca5a5; background: #fff7f7; }
.invalid-builder button:disabled { opacity: .55; cursor: not-allowed; }
.concept-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin: 18px 0;
}
.concept-strip > div {
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #f8fafc;
}
.concept-strip strong, .concept-strip span { display: block; }
.concept-strip span { color: var(--muted); margin-top: 4px; font-size: .85rem; }
.scenario-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 18px 0;
}
.scenario-grid > div {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    background: #f8fafc;
}
.scenario-grid strong, .scenario-grid span { display: block; }
.scenario-grid span { color: var(--muted); margin-top: 5px; line-height: 1.45; }
.query-box.placeholder { opacity: .75; }
.plan-explanation { margin: 10px 0 0; padding: 11px 13px; border-radius: 12px; }
.ok-text { background: #f0fdf4; color: #166534; }
.warn-text { background: #fffbeb; color: #92400e; }
.comparison-filter {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid var(--line);
}
.comparison-filter span { color: var(--muted); font-weight: 800; }
.comparison-summary {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    padding: 12px 14px;
    border-radius: 14px;
}
.write-forms {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 16px;
    margin-top: 16px;
}
.write-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px;
    background: #f8fafc;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.write-card > div:first-child,
.write-card > button,
.write-card > p { grid-column: 1 / -1; }
.write-result {
    border: 1px solid #86efac;
    background: #f0fdf4;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 16px;
}
.write-result > strong { font-size: 1.05rem; }
.write-result-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 12px 0;
}
.write-result-grid span {
    display: grid;
    gap: 3px;
    background: white;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    padding: 10px;
    color: var(--muted);
    font-size: .82rem;
}
.write-result-grid b { color: var(--text); font-size: .95rem; }
.terminal-block {
    background: #0f172a;
    color: #dbeafe;
    border-radius: 16px;
    padding: 16px;
    overflow-x: auto;
    white-space: pre-wrap;
}

@media (max-width: 1180px) {
    .metrics-six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .scenario-grid, .concept-strip, .write-result-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .write-forms { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .metrics-six, .scenario-grid, .concept-strip, .write-result-grid, .write-card { grid-template-columns: 1fr; }
}
