*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --navy: #1a3a6b;
    --navy-dark: #142e56;
    --navy-light: #EBF1FA;
    --navy-border: #a0bce0;
    --navy-muted: #5580b0;
    --green: #27500A;
    --green-light: #EAF3DE;
    --green-border: #97C459;
    --red-light: #FCEBEB;
    --red-border: #F09595;
    --red-text: #501313;
    --text: #1a1a1a;
    --text-muted: #6b7280;
    --text-faint: #9ca3af;
    --bg: #f5f6f8;
    --surface: #ffffff;
    --border: #e2e5ea;
    --border-mid: #c8cdd6;
    --radius: 10px;
    --radius-sm: 7px;
}

body {
    font-family: 'Source Sans 3', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 2rem 1rem;
}

.app-wrap {
    max-width: 760px;
    margin: 0 auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    width: 100%;
}

header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 2rem 2.5rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 100;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
}

.escudo {
    width: 78px;
    height: 78px;
    flex-shrink: 0;
}

.logo-text h1 {
    font-family: 'Lora', serif;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text);
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.logo-text p {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 2px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
}

.header-nav {
    display: flex;
    gap: 6px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-sm);
    background: none;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.nav-btn:hover {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border-mid);
}

.nav-btn.active {
    background: var(--navy);
    color: #e8f0fb;
    border-color: var(--navy);
}

.nav-btn svg {
    flex-shrink: 0;
}

main {
    flex: 1;
    padding: 1.25rem 2.5rem 2rem;
    width: 100%;
}

.tool-panel {
    display: none;
}

.tool-panel.active {
    display: block;
}

.tool-header {
    margin-bottom: 1.75rem;
}

.tool-header h2 {
    font-family: 'Lora', serif;
    font-size: 22px;
    font-weight: 500;
    margin-bottom: 6px;
}

.tool-header p {
    font-size: 16px;
    color: var(--text-muted);
    line-height: 1.55;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.card-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 1.1rem;
}

.step-badge {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--navy);
    color: #e8f0fb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.drop-zone {
    border: 1.5px dashed var(--border-mid);
    border-radius: var(--radius-sm);
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    background: var(--bg);
}

.drop-zone:hover,
.drop-zone.over {
    background: var(--navy-light);
    border-color: var(--navy);
}

.drop-zone .dz-icon {
    margin: 0 auto 10px;
    display: block;
    color: var(--text-faint);
}

.drop-zone p {
    font-size: 16px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.drop-zone span {
    font-size: 14px;
    color: var(--text-faint);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 8px 20px;
    background: var(--navy);
    color: #e8f0fb;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 15px;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
}

.btn-primary:hover {
    background: var(--navy-dark);
}

.file-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--navy-light);
    border: 1px solid var(--navy-border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    margin-top: 8px;
}

.file-row-info {
    flex: 1;
    min-width: 0;
}

.file-row-info strong {
    font-size: 15px;
    font-weight: 500;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--navy-dark);
}

.file-row-info span {
    font-size: 13px;
    color: var(--navy-muted);
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--navy-muted);
    padding: 4px 7px;
    border-radius: 5px;
    font-size: 18px;
    line-height: 1;
    transition: background 0.1s, color 0.1s;
}

.icon-btn:hover {
    background: #c8d9ee;
    color: var(--navy-dark);
}

.icon-btn:disabled {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

.order-badge {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--navy);
    color: #e8f0fb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    flex-shrink: 0;
}

.merge-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 1.1rem;
}

.stat-card {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    text-align: center;
    border: 1px solid var(--border);
}

.stat-card .num {
    font-size: 24px;
    font-weight: 500;
    color: var(--navy);
}

.stat-card .lbl {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.file-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.empty-hint {
    text-align: center;
    padding: 0.75rem 0;
    font-size: 13px;
    color: var(--text-faint);
}

.divider {
    height: 1px;
    background: var(--border);
    margin: 0.5rem 0 1.25rem;
}

.btn-process {
    width: 100%;
    padding: 14px;
    background: var(--navy);
    color: #e8f0fb;
    font-family: 'Lora', serif;
    font-size: 17px;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
}

.btn-process:hover:not(:disabled) {
    background: var(--navy-dark);
}

.btn-process:disabled {
    opacity: 0.38;
    cursor: not-allowed;
}

.status-box {
    display: none;
    margin-top: 1rem;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    align-items: center;
    gap: 10px;
    line-height: 1.45;
}

.status-box.loading {
    display: flex;
    background: var(--navy-light);
    color: var(--navy-dark);
    border: 1px solid var(--navy-border);
}

.status-box.success {
    display: flex;
    background: var(--green-light);
    color: var(--green);
    border: 1px solid var(--green-border);
}

.status-box.error {
    display: flex;
    background: var(--red-light);
    color: var(--red-text);
    border: 1px solid var(--red-border);
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--navy-border);
    border-top-color: var(--navy);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.btn-dl {
    display: none;
    width: 100%;
    margin-top: 0.75rem;
    padding: 12px;
    background: var(--green);
    color: var(--green-light);
    font-family: 'Source Sans 3', sans-serif;
    font-size: 16px;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transition: background 0.15s;
}

.btn-dl:hover {
    background: #173404;
}

.text-input {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-sm);
    font-family: 'Source Sans 3', sans-serif;
    font-size: 16px;
    color: var(--text);
    background: var(--bg);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.text-input:focus {
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(26, 58, 107, 0.1);
}

.text-input::placeholder {
    color: var(--text-faint);
}

.name-hint {
    font-size: 12px;
    color: var(--text-faint);
    margin-top: 6px;
}

.name-hint strong {
    color: var(--navy);
    font-weight: 500;
}

.url-preview {
    display: none;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--navy-muted);
    padding: 0 2px;
}

.url-preview a {
    color: var(--navy);
    text-decoration: underline;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 460px;
    display: inline-block;
}

footer {
    text-align: center;
    padding: 1.5rem;
    font-size: 11px;
    color: var(--text-faint);
    letter-spacing: 0.04em;
    border-top: 1px solid var(--border);
    background: transparent;
}

@media (max-width: 550px) {
    body {
        padding: 1rem 0.5rem;
    }
    header {
        flex-direction: column;
        align-items: stretch;
        gap: 1.25rem;
        padding: 1.5rem;
    }
    .logo-area {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 10px;
    }
    .logo-text h1 {
        font-size: 16px;
    }
    .header-nav {
        width: 100%;
    }
    .nav-btn {
        width: 100%;
        justify-content: center;
    }
    main {
        padding: 1.25rem 1.5rem 2rem;
    }
    .card {
        padding: 1.25rem;
    }
}
