*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #1367b4;
    --primary-dark: #0a466d;
    --primary-soft: #c7eafa;
    --accent: #ea7c09;
    --text-muted: #b4b4b4;
    --accent-soft: #fff3e7;
    --bg-main: #eef6fb;
    --bg-card: #ffffff;
    --border: #d9e5ed;
    --text-main: #1f1f1f;
    --text-soft: #666666;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-main);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
#sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 1.25rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.logo-img {
    max-width: 100%;
    margin-bottom: 1rem;
    border-radius: 4px;
}

.info-box {
    background: var(--primary-soft);
    border: 1px solid var(--primary);
    border-radius: 6px;
    padding: 0.75rem;
    font-size: 0.8rem;
    line-height: 1.5;
}

.info-box a { color: var(--primary-dark); }

.s-section { margin-top: 1.1rem; }

.s-section h3 {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
}

.s-section label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
    margin-bottom: 0.35rem;
    cursor: pointer;
}

.field-label {
    font-size: 0.8rem;
    color: var(--primary-dark);
    margin: 0.55rem 0 0.2rem;
}

.s-section input[type="text"] {
    width: 100%;
    padding: 0.38rem 0.55rem;
    border: 1px solid var(--text-muted);
    border-radius: 4px;
    font-size: 0.85rem;
}

hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ── Main ── */
#main {
    flex: 1;
    padding: 2rem 2.5rem;
    max-width: 960px;
}

.app-title {
    font-size: 1.55rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.app-caption {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-bottom: 1.5rem;
}

.description {
    background: white;
    border-radius: 8px;
    padding: 1.1rem 1.3rem;
    font-size: 0.91rem;
    line-height: 1.65;
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

code {
    background: var(--primary-soft);
    color: var(--primary-dark);
    padding: 0.1em 0.3em;
    border-radius: 3px;
    font-size: 0.88em;
}

/* ── Tabs ── */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1rem;
}

.tab-btn {
    padding: 0.55rem 1.1rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.93rem;
    color: var(--text-soft);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Upload area ── */
.upload-area {
    border: 2px dashed var(--text-muted);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    background: white;
    transition: border-color 0.2s, background 0.2s;
    user-select: none;
}

.upload-area:hover,
.upload-area.drag-over { border-color: var(--accent); background: var(--accent-soft); }

.upload-area input[type="file"] { display: none; }

.upload-icon { font-size: 2.2rem; margin-bottom: 0.4rem; }

.upload-area p { color: var(--text-soft); font-size: 0.88rem; margin-top: 0.2rem; }

#file-list {
    margin-top: 0.6rem;
    font-size: 0.83rem;
    color: var(--primary-dark);
    line-height: 1.7;
}

textarea {
    width: 100%;
    padding: 0.7rem;
    border: 1px solid var(--text-muted);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
    background: white;
}

/* ── Process button ── */
.btn-process {
    display: block;
    width: 100%;
    padding: 0.72rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.97rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1rem;
    transition: background 0.2s;
}

.btn-process:hover { filter: brightness(0.92); }

/* ── Banners ── */
.success-box {
    background: var(--primary-soft);
    border: 1px solid var(--primary);
    border-radius: 6px;
    padding: 0.7rem 1rem;
    color: var(--primary-dark);
    font-size: 0.88rem;
    margin-bottom: 1rem;
}

.info-banner {
    background: var(--primary-soft);
    border: 1px solid var(--primary);
    border-radius: 6px;
    padding: 0.7rem 1rem;
    color: var(--primary-dark);
    font-size: 0.88rem;
}

/* ── Metrics ── */
.metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.9rem;
    margin-bottom: 1.5rem;
}

.metric-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
}

.metric-value { color: var(--primary-dark); font-size: 1.75rem; font-weight: 700; }
.metric-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

.ttr-help {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 0.65rem;
    font-weight: 700;
    cursor: help;
    vertical-align: middle;
    margin-left: 3px;
}
.ttr-help:hover { background: var(--accent); color: white; }

/* ── Frequency bars ── */
.freq-section { margin-top: 1.5rem; }
.freq-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.35rem;
    font-size: 0.82rem;
}
.freq-word {
    min-width: 130px;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-main);
}
.freq-bar-bg {
    flex: 1;
    background: var(--primary-soft);
    border-radius: 3px;
    height: 8px;
}
.freq-bar {
    height: 8px;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s ease;
}
.freq-count { color: var(--text-muted); font-size: 0.75rem; min-width: 28px; text-align: right; }

/* ── Table ── */
.section-title { font-size: 1rem; font-weight: 700; margin-bottom: 0.8rem; }

.table-wrap {
    overflow-x: auto;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 0.5rem;
}

table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }

th {
    background: var(--primary-soft);
    color: var(--primary-dark);
    padding: 0.55rem 0.75rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--primary);
    white-space: nowrap;
}

td {
    padding: 0.45rem 0.75rem;
    border-bottom: 1px solid var(--border);
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--primary-soft); }

td[contenteditable] { cursor: text; }
td[contenteditable]:hover { background: var(--accent-soft); }
td[contenteditable]:focus {
    outline: none;
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1px var(--accent);
    white-space: normal;
    overflow: visible;
    max-width: none;
}

/* ── Añadir etiquetas tras procesar ── */
.add-label {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.add-label input {
    flex: 1;
    min-width: 0;
    padding: 0.38rem 0.55rem;
    border: 1px solid var(--text-muted);
    border-radius: 4px;
    font-size: 0.85rem;
}

.btn-add-label {
    padding: 0.38rem 0.8rem;
    border: 1px dashed var(--accent);
    border-radius: 6px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.82rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.18s;
}
.btn-add-label:hover { color: white; background: var(--accent); border-style: solid; }

.btn-remove-label {
    border: none;
    background: none;
    color: var(--primary-dark);
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    margin-left: 0.2rem;
    opacity: 0.55;
}
.btn-remove-label:hover { opacity: 1; color: var(--accent); }

.table-note { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 1.3rem; }

/* ── Export buttons ── */
.export-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.7rem;
}

.btn-export {
    padding: 0.6rem;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--accent);
    color: white;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.18s;
}

.btn-export:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    filter: brightness(0.92);
}

.btn-export-stats {
    display: block;
    width: 100%;
    padding: 0.5rem;
    border: 1px dashed var(--accent);
    border-radius: 6px;
    background: var(--accent-soft);
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--accent);
    margin-top: 0.55rem;
    transition: all 0.18s;
}
.btn-export-stats:hover { border-color: var(--accent); color: white; background: var(--accent); }

.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ── About button ── */
.about-btn {
    background: none;
    border: 1px solid var(--text-muted);
    border-radius: 20px;
    padding: 0.2rem 0.7rem;
    font-size: 0.78rem;
    color: var(--primary-dark);
    cursor: pointer;
    margin-left: 0.6rem;
    vertical-align: middle;
    transition: all 0.15s;
}
.about-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Modal ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 100;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal-box {
    background: white;
    border-radius: 10px;
    padding: 2rem 2.2rem;
    max-width: 620px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1.2rem;
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}
.modal-close:hover { color: var(--accent); }

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.3rem;
}

.name-layer {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}
.name-tag {
    background: var(--primary);
    color: white;
    font-weight: 700;
    font-size: 0.78rem;
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    white-space: nowrap;
    margin-top: 0.1rem;
    flex-shrink: 0;
}
.name-tag.alt { background: var(--primary-dark); }
.name-tag.soft { background: var(--accent); }

.name-layer p {
    font-size: 0.88rem;
    line-height: 1.55;
    color: var(--text-main);
}
.name-layer p strong { color: var(--primary-dark); }

.modal-section {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin: 1.4rem 0 0.7rem;
}

/* ── Guía de uso ── */
.guide-btn { margin-left: 0.3rem; }

.guide p,
.guide li {
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--text-main);
}
.guide p { margin-bottom: 0.6rem; }
.guide ul { padding-left: 1.2rem; margin-bottom: 0.6rem; }
.guide li { margin-bottom: 0.4rem; }
.guide li strong { color: var(--primary-dark); }
.guide code { font-size: 0.82rem; }

.guide .guide-tip {
    background: var(--accent-soft);
    border-left: 3px solid var(--accent);
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    font-size: 0.84rem;
}

.bio-text {
    font-size: 0.88rem;
    line-height: 1.65;
    color: var(--text-main);
}
