.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-d); }

#app-screen { display: none; min-height: 100vh; flex-direction: column; }

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-brand {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

.tab-bar-admin {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    gap: 4px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.tab-bar-admin::-webkit-scrollbar { display: none; }
.tab-bar-admin .tab-btn, .tab-bar-admin a { flex: 0 0 auto; }

.tab-bar-admin .tab-btn {
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s;
    margin-bottom: -1px;
}

.tab-bar-admin .tab-btn:hover { color: var(--text); }
.tab-bar-admin .tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.content { padding: 28px 24px; max-width: 1100px; }

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.section-header h2 { font-size: 18px; font-weight: 700; }

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 20px;
}

table { width: 100%; border-collapse: collapse; }
thead { background: var(--surface2); }
th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
td {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    vertical-align: middle;
}
tr:hover td { background: rgba(255,255,255,0.02); }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.badge-contable { background: rgba(16,185,129,0.15); color: var(--accent); }
.badge-granel { background: rgba(245,158,11,0.15); color: var(--warn); }
.badge-ok { background: rgba(16,185,129,0.2); color: var(--accent); }
.badge-warn { background: rgba(245,158,11,0.2); color: var(--warn); }
.badge-danger { background: rgba(239,68,68,0.2); color: var(--danger); }

.actions { display: flex; gap: 6px; }

.form-panel {
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    display: none;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:translateY(0); } }

.form-panel h3 { font-size: 15px; font-weight: 600; margin-bottom: 20px; color: var(--accent); }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.form-grid select {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
}
.form-grid select:focus { outline: none; border-color: var(--accent); }
.form-grid input { width: 100%; background: var(--surface2); border:1px solid var(--border); border-radius:var(--radius); color:var(--text); padding:10px 14px; font-size:14px; font-family:inherit; }
.form-grid input:focus { outline:none; border-color:var(--accent); }

.form-actions { display: flex; gap: 10px; }

.empty { padding: 40px; text-align: center; color: var(--text-muted); font-size: 13px; }

.boceto-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: hidden;
}
.boceto-header {
    padding: 16px 20px;
    background: var(--surface2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}
.boceto-header:hover { background: var(--border); }
.boceto-title { font-weight: 600; font-size: 14px; }
.boceto-title span { color: var(--text-muted); font-weight: 400; margin-left: 8px; }
.boceto-body { display: none; padding: 16px 20px; }
.boceto-body.expanded { display: block; }
.boceto-table { width: 100%; border-collapse: collapse; }
.boceto-table th {
    padding: 8px 12px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
}
.boceto-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.boceto-table tr:last-child td { border-bottom: none; }
.boceto-table input[type=number] {
    width: 80px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 6px 8px;
    font-size: 13px;
}
.boceto-table input:focus { outline: none; border-color: var(--accent); }
.boceto-actions { margin-top: 12px; display: flex; gap: 8px; }

.admin-panel { display: none; }
.admin-panel.active { display: block; }

#toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    display: none;
    z-index: 9999;
    box-shadow: var(--shadow);
    animation: fadeIn 0.2s ease;
}
#toast.ok { background: var(--accent); color: #fff; }
#toast.error { background: var(--danger); color: #fff; }
#toast.warn { background: var(--warn); color: #1a1a1a; }

/* ===== F-017: Pilares Admin ===== */
.pilar-panel { display: none; }
.pilar-panel.active { display: block; }

.sub-nav {
    display: flex; gap: 4px; margin-bottom: 24px;
    overflow-x: auto; white-space: nowrap;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
}
.sub-nav::-webkit-scrollbar { display: none; }
.sub-nav-btn {
    flex: 0 0 auto; padding: 8px 16px; border-radius: 20px;
    background: var(--surface2); border: 1px solid var(--border);
    color: var(--text-muted); font-size: 12px; font-weight: 600;
    cursor: pointer; transition: all 0.15s;
}
.sub-nav-btn:hover { border-color: var(--accent); color: var(--text); }
.sub-nav-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.sub-panel { display: none; }
.sub-panel.active { display: block; }

.rep-preview-wrap { margin-bottom: 20px; }

.rep-header {
    background: var(--surface2); border-radius: var(--radius);
    padding: 12px 16px; margin-bottom: 16px;
}
.rep-section {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
}
.rep-boceto-preview {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 6px; padding: 12px; font-size: 11px;
    max-height: 250px; overflow: auto; white-space: pre-wrap;
    font-family: 'Courier New', monospace; margin: 0;
}

/* ===== F-017: Botón Ir a Operación ===== */
#btn-ir-operacion {
    text-decoration: none; display: flex; align-items: center; gap: 4px;
    color: var(--text-muted); font-size: 12px; white-space: nowrap;
}
#btn-ir-operacion:hover { color: var(--accent); border-color: var(--accent); }

/* ===== S020 / F-014: Trazabilidad de operadores ===== */
#sub-panel-trazabilidad .table-wrap { margin-top: 12px; }
#trazabilidad-tbody td { font-size: 13px; }
#trazabilidad-tbody td[data-col="cantidad"] { text-align: right; font-variant-numeric: tabular-nums; }
#sub-panel-trazabilidad .section-header input[type="text"],
#sub-panel-trazabilidad .section-header input[type="date"] { min-width: 130px; }