:root {
    --bg: #f4f6fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #1d4ed8;
    --primary-hover: #1e40af;
    --secondary: #475569;
    --success: #15803d;
    --danger: #b91c1c;
    --border: #e5e7eb;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.container {
    width: min(1200px, calc(100% - 2rem));
    margin: 0 auto;
}

.site-header {
    background: #0f172a;
    color: #fff;
    padding: 1rem 0;
    margin-bottom: 2rem;
}

.site-header h1 {
    margin: 0 0 0.75rem;
    font-size: 1.5rem;
}

.site-header nav {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.site-header a {
    color: #cbd5e1;
    text-decoration: none;
}

.site-header a.active,
.site-header a:hover {
    color: #fff;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.25rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.steps article {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
}

.step-number {
    display: inline-flex;
    width: 2rem;
    height: 2rem;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
}

.btn {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 0.65rem 1rem;
    text-decoration: none;
    cursor: pointer;
    font-size: 0.95rem;
}

.btn:hover {
    background: var(--primary-hover);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--secondary);
}

.btn-success {
    background: var(--success);
}

.btn-small {
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
}

.muted {
    color: var(--muted);
}

.error {
    color: var(--danger);
}

.message {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 10px;
}

.message.success {
    background: #ecfdf5;
    color: #065f46;
}

.message.error {
    background: #fef2f2;
    color: #991b1b;
}

.hidden {
    display: none !important;
}

.plantillas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}

.plantilla-item {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
}

.plantilla-item .actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

input[type="text"],
input[type="number"],
input[type="file"],
select {
    display: block;
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
}

.editor-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1rem;
    align-items: start;
}

.editor-main {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 1rem;
}

.editor-workspace {
    grid-column: 1 / 2;
}

.field-panel {
    grid-column: 2 / 3;
    grid-row: 1 / span 2;
}

.canvas-wrapper {
    position: relative;
    min-height: 500px;
    overflow: auto;
    background: #e2e8f0;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.canvas-placeholder {
    padding: 2rem;
}

.canvas-stage {
    position: relative;
    display: inline-block;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.15);
}

#pdf-canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

.field-element {
    position: absolute;
    z-index: 10;
    border: 2px dashed var(--primary);
    background: rgba(29, 78, 216, 0.12);
    color: #1e3a8a;
    padding: 0.25rem 0.5rem;
    cursor: move;
    font-size: 12px;
    font-weight: 700;
    border-radius: 6px;
    min-width: 40px;
    min-height: 24px;
    white-space: nowrap;
}

.field-element.selected {
    border-style: solid;
    background: rgba(29, 78, 216, 0.22);
    z-index: 10;
}

.field-element.qr-field {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.08);
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    border-bottom: 1px solid var(--border);
    padding: 0.65rem;
    text-align: left;
    font-size: 0.92rem;
}

th {
    background: #f8fafc;
}

.errors-list {
    background: #fef2f2;
    color: #991b1b;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.errors-list ul {
    margin: 0.5rem 0 0;
    padding-left: 1.2rem;
}

.progress-container {
    margin-top: 1rem;
}

.progress-bar {
    width: 100%;
    height: 18px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #2563eb, #22c55e);
    transition: width 0.25s ease;
}

#progress-text {
    margin-top: 0.5rem;
    font-weight: 600;
}

@media (max-width: 960px) {
    .editor-layout,
    .editor-main {
        grid-template-columns: 1fr;
    }

    .field-panel {
        grid-column: auto;
        grid-row: auto;
    }
}
